// index.js
const Weixinbot = require('weixinbot')

// will send qrcode to your email address
const bot = new Weixinbot({receiver: '393978119@qq.com'})

// will emit when bot fetch a new qrcodeUrl
bot.on('qrcode', (qrcodeUrl) => {
	console.log(qrcodeUrl)
	document.getElementById('login').src = qrcodeUrl;
})

bot.on('friend', (msg) => {
	console.log(msg.FromUserName);
	console.log(msg);
	if (msg.FromUserName == msg.ToUserName) {
		document.getElementById('index_nickname').innerText = msg.Member.NickName;
		document.getElementById('index_signature').innerText = msg.Member.Signature;
	}
	//   console.log(bot.fetchContact());
	//   console.log(msg.Member.NickName + ': ' + msg.Content)
	//bot.sendText(msg.FromUserName, 'Got it')
})

bot.run()
